var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = (function () {
    function e() {}
    return (
        (e.getWordCount = function (e) {
            for (var t = 0, o = 0; o < e.length; ++o) this.isChWord(e.charCodeAt(o)) ? (t += 2) : ++t;
            return t;
        }),
        (e.isChWord = function (e) {
            return e > 255 || e < 0;
        }),
        (e.getRandomInt = function (e, t) {
            return Math.floor(Math.random() * (t - e + 1)) + e;
        }),
        (e.getRandom = function (e, t) {
            return e + Math.random() * (t - e);
        }),
        (e.randomStr = function (t) {
            for (var o = "", n = 0; n < t; n++) {
                var a = e.getRandomInt(0, 35);
                o += a <= 9 ? a : String.fromCharCode("a".charCodeAt(0) + a - 10);
            }
            return o;
        }),
        (e.fixNumByZero = function (e, t) {
            for (var o = e.toString(), n = o.length; n < t; n++) o = "0" + o;
            return o;
        }),
        (e.getCommaNumString = function (t, o, n) {
            void 0 === o && (o = 3), void 0 === n && (n = ",");
            var a = t >= 0;
            t = t >= 0 ? t : -t;
            for (var i = 1, r = 0; r < o; r++) i *= 10;
            var s = [];
            do {
                s.push(t % i), (t = Math.floor(t / i));
            } while (t > 0);
            for (var l = a ? "" : "-", c = s.length - 1; c >= 0; c--)
                c == s.length - 1 ? (l += s[c]) : (l += n + e.fixNumByZero(s[c], o));
            return l;
        }),
        (e.convertStrEllipsis = function (e, t, o) {
            void 0 === o && (o = "...");
            for (var n = 0, a = e, i = 0; i < e.length; ++i) {
                if (n >= t) {
                    a = e.slice(0, n) + o;
                    break;
                }
                this.isChWord(e.charCodeAt(i)) ? (n += 2) : ++n;
            }
            return a;
        }),
        (e.getTimeStrByNum = function (e, t, o) {
            void 0 === t && (t = !1);
            var n = parseInt("" + (e % 864e5) / 36e5),
                a = parseInt("" + (e % 36e5) / 6e4),
                i = (e % 6e4) / 1e3,
                r = "";
            return (
                1 == o
                    ? (n > 0 && (r = n + (t ? "小时" : ":")),
                      a > 0 && (r += a + (t ? "分钟" : ":")),
                      i > 0 && ((r += parseInt("" + i)), (r += t ? "秒" : "")))
                    : 2 == o &&
                      (a > 0 ? ((r += a < 10 ? "0" + parseInt("" + a) : parseInt("" + a)), (r += ":")) : (r += "00:"),
                      (r += i > 0 ? (i < 10 ? "0" + parseInt("" + i) : parseInt("" + i)) : "00")),
                r
            );
        }),
        (e.getBtnNameType = function (e, t) {
            var o = e.target.name;
            return this.getNameType(o, t);
        }),
        (e.getNameType = function (e, t) {
            var o = t.length;
            return e.substr(o, e.length - o);
        }),
        (e.getCoinByString = function (e) {
            var t = "";
            if (e > 9999) {
                var o = Math.floor(e / 1e4),
                    n = Math.floor((e % 1e4) / 100);
                t = o + "." + (n < 10 ? "0" + n : n + "") + "w";
            } else t = "" + e;
            return t;
        }),
        (e.lerp = function (e, t, o) {
            return e + (t - e) * o;
        }),
        (e.saveJSON = function (e, t) {
            if (e) {
                t || (t = "json.json"), "object" == typeof e && (e = JSON.stringify(e, void 0, 4));
                var o = new Blob([e], {type: "text/json"}),
                    n = document.createEvent("MouseEvents"),
                    a = document.createElement("a");
                (a.download = t),
                    (a.href = window.URL.createObjectURL(o)),
                    (a.dataset.downloadurl = ["text/json", a.download, a.href].join(":")),
                    n.initMouseEvent("click", !0, !1, window, 0, 0, 0, 0, 0, !1, !1, !1, !1, 0, null),
                    a.dispatchEvent(n);
            } else alert("保存的数据为空");
        }),
        e
    );
})();
o.default = n;
